clear all
set more off
estimates clear
eststo clear


*******insert path ***********************
global path="C:\Users\tjb0217\Box\Tyler\One off tasks\BeamanDillon_JDE_Repl"

cd "$path"
global data "$path\Data"
global code "$path\Codes"	
global output "$path\tables"
local outfilename = "$path\tables\tables.csv"


use "Data\BeamanDillon_JDE_2017.dta"

*************************** Table 1 *******************************
******************** Network Characteristics **********************
*******************************************************************

#d ;
tabstat ctr_11_mf_deg ctr_11_mf_bet ctr_11_mf_evc notconnected, by(female) stat(n mean sd)	;

foreach var in ctr_11_mf_deg ctr_11_mf_bet ctr_11_mf_evc { ;
		forvalues n=0/1 { ;
			sum `var'  if female==`n' ;
			matrix m`var'`n'=r(mean) ;
			matrix sd`var'`n'=r(sd) ;
			matrix N`n'=r(N) ;
		} ;
	local lbl`var': variable label `var' ;
	matrix `var'= m`var'0, m`var'1 \ sd`var'0, sd`var'1 ;
	matrix rownames `var' = "`lbl`var''" "." ;
} ;

foreach var in notconnected {	;
		forvalues n=0/1 { ;
			sum `var'  if female==`n' ;
			matrix m`var'`n'=r(mean) ;
		} ;
	local lbl`var': variable label `var' ;
	matrix `var'= m`var'0, m`var'1 \ N0, N1 ;
	matrix rownames `var' = "`lbl`var''" "Observations (Household-gender)" ;
} ;
	
matrix e_cont=ctr_11_mf_deg\ctr_11_mf_bet\ctr_11_mf_evc\notconnected ;
#d cr
frmttable using "$output\Table1", replace sdec(2, 2, 2) statmat(e_cont) title("Table 1. Panel A.") ///
	coljust(l;c) ctitles("" , Male, Female)


*************************** Table 2 *******************************
********************** Randomization check ************************
*******************************************************************

#delimit ;
global satis_list = "snc_08_hh_gen_comp_all snc_08_hh_gen_comp_women snc_08_hh_gen_livestock 
		snc_08_hh_gen_assets snc_08_hh_gen_agequip mudfloors wellwater snc_08_hh_raw_a_q4_nbat 
		snc_08_mf_raw_s1_q1_nplots millet_main rice_main households_08 households_11";
global indep_list ="degree_treatment between_treatment cons";
global nv = wordcount("$satis_list");
disp "$nv";

cap prog drop fill;
program def fill;
    syntax, i(real);
    qui {;
		cap replace nobs = e(N) if _n == ((`i' * 3)  - 2);
		cap sum ${outname`i'} if degree_treatment == 0 & between_treatment == 0 & e(sample) == 1 ;
        cap replace depvarcons = r(mean) if _n == ((`i' * 3) - 2);
        cap replace depvarcons = r(sd) if _n == ((`i' * 3) - 1);
		cap sum ${outname`i'} if degree_treatment == 1 & between_treatment == 0 & e(sample) == 1 ;
		cap replace depvardegree = r(mean) if _n == ((`i' * 3) - 2);
		cap replace depvardegree = r(sd) if _n == ((`i' * 3) - 1);
		cap sum ${outname`i'} if degree_treatment == 0 & between_treatment == 1 & e(sample) == 1 ;
		cap replace depvarbetween = r(mean) if _n == ((`i' * 3) - 2);
		cap replace depvarbetween = r(sd) if _n == ((`i' * 3) - 1);
};
end;

local i = 0;
foreach var of varlist $satis_list {;
	local i = `i' + 1;
	global outname`i' = "`var'";
	global label`i': variable label `var';
};

global regout = "deplabel depvardegree depvarbetween depvarcons nobs pvalue";
qui for any depends deplabel: gen str1 X = "";
qui for any depvardegree depvarbetween depvarcons nobs pvalue: gen X=.;

global temp1=$nv-2;
global temp2=$nv-1;

forvalues i = 1/$temp1 {;	
    replace depends = "${outname`i'}" if _n == ((`i' * 3) - 2);
    replace deplabel = "${label`i'}" if _n == ((`i' * 3) - 2);

	reg ${outname`i'} $indep_list, noc cluster(vill_id);
	fill, i(`i');
	
	testparm degree_treatment between_treatment;	
	replace pvalue=r(p) if _n == ((`i' * 3)  - 2);
};

forvalues i = $temp2/$nv {;	
    replace depends = "${outname`i'}" if _n == ((`i' * 3) - 2);
    replace deplabel = "${label`i'}" if _n == ((`i' * 3) - 2);

	reg ${outname`i'} $indep_list if vill_tag==1, noc ;
	fill, i(`i');
	
	testparm degree_treatment between_treatment;	
	replace pvalue=r(p) if _n == ((`i' * 3)  - 2);
};

***OUTSHEETING **;
preserve;
keep $regout;
drop if _n > $nv * 3+ 50;
outsheet using "$output\Table2.csv", comma replace;
restore;
#delimit cr

*************************** Table 3 *******************************
******************** Balance Test By Gender ***********************
*******************************************************************

lab var snc_08_hh_gen_livestock "Livestock Count"
lab var snc_08_hh_gen_agequip "Agricultural Capital Count"
lab var snc_08_hh_gen_comp_adeq "Adult Equivalent Household Size"
lab var rizirr_exp "Experience with Irrigated Rice"
lab var millet_exp "Experience with Millet"
lab var sorgho_exp "Experience with Sorghum"
lab var ctr_08_hh_deg "Degree"
lab var ctr_08_hh_bet "Betweeness"
lab var ctr_08_hh_evc "Eigenvector Centrality"
#d ;
global depvars "snc_08_hh_gen_livestock snc_08_hh_gen_agequip snc_08_hh_gen_comp_adeq rizirr_exp 
		millet_exp sorgho_exp ctr_08_hh_deg ctr_08_hh_bet ctr_08_hh_evc" ;
global nv = wordcount("$depvars") ;
disp "$nv" ;

local cnt = 0 ;
foreach cond in "degree_treatment==0 & between_treatment==0" "degree_treatment==1 & between_treatment==0"	///
	"degree_treatment==0 & between_treatment==1"	{ ;
		local cnt = `cnt' + 1 ;
		foreach var in snc_08_hh_gen_livestock snc_08_hh_gen_agequip snc_08_hh_gen_comp_adeq { ;	
			forvalues n=0/1 { ;
					sum `var' if seed_m==`n' & `cond' & seed==1 ;
					matrix m`var'`n'=r(mean) ;
					matrix sd`var'`n'=r(sd) ;
				} ;
			local lbl`var': variable label `var' ;
			reg `var' seed_m if `cond' & seed==1, cluster(vill_id) ;
			testparm seed_m ;
			matrix pv`var'=r(p) ;
			matrix `var'`cnt'= m`var'1, m`var'0, pv`var' \ sd`var'1, sd`var'0 , . ;
			matrix rownames `var'`cnt' = "`lbl`var''" "." ;
		} ; 

		foreach var in rizirr_exp millet_exp sorgho_exp { ;	
			forvalues n=0/1 { ;
					sum `var'  if seed_m==`n' & `cond' & seed==1 ;
					matrix m`var'`n'=r(mean) ;
				} ;
			local lbl`var': variable label `var' ;
			reg `var' seed_m if `cond' & seed==1, cluster(vill_id) ;
			testparm seed_m ;
			matrix pv`var'=r(p) ;
			matrix `var'`cnt'= m`var'1, m`var'0, pv`var' ;
			matrix rownames `var'`cnt'= "`lbl`var''" ;
		} ; 

		foreach var in ctr_08_hh_deg ctr_08_hh_bet ctr_08_hh_evc { ;	
			forvalues n=0/1 { ;
					sum `var'  if seed_m==`n' & `cond' & seed==1 ;
					matrix m`var'`n'=r(mean) ;
					matrix sd`var'`n'=r(sd) ;
				} ;
			local lbl`var': variable label `var' ;
			reg `var' seed_m if `cond' & seed==1, cluster(vill_id) ;
			testparm seed_m ;
			matrix pv`var'=r(p) ;
			matrix `var'`cnt'= m`var'1, m`var'0, pv`var' \ sd`var'1, sd`var'0 , . ;
			matrix rownames `var'`cnt'= "`lbl`var''" "." ;
		} ; 
	matrix e_cont_`cnt'=(snc_08_hh_gen_livestock`cnt'\snc_08_hh_gen_agequip`cnt'\snc_08_hh_gen_comp_adeq`cnt'
		\rizirr_exp`cnt'\millet_exp`cnt'\sorgho_exp`cnt'\ctr_08_hh_deg`cnt'\ctr_08_hh_bet`cnt'\ctr_08_hh_evc`cnt') ;
};	
#d cr

frmttable using "$output\Table3A", replace sdec(2, 2, 3) statmat(e_cont_1) title("Table 3. Random Treated Node Balancing Test")	/// 
	coljust(l;c) ctitles("" , Male Treated Node, Female Treated Node, P-value) 
frmttable using "$output\Table3B", replace sdec(2, 2, 3) statmat(e_cont_2) title("Table 3. Degree Treated Node Balancing Test")	/// 
	coljust(l;c) ctitles("" , Male Treated Node, Female Treated Node, P-value) 
frmttable using "$output\Table3C", replace sdec(2, 2, 3) statmat(e_cont_3) title("Table 3. Between Treated Node Balancing Test") /// 
	coljust(l;c) ctitles("" , Male Treated Node, Female Treated Node, P-value) 
	
	

*************************** Table 4 *******************************
***************** Access to treated nodes *****************
*******************************************************************

foreach var in ctr_11_mf_deg ctr_11_mf_bet ctr_11_mf_evc { 
 
			gen `var'_f=`var' if female == 1 
			replace `var'_f =. if female == 0
			gen `var'_m=`var' if female == 0
			replace `var'_m =. if female == 1
		} 

foreach i in deg bet clo evc {
	sum ctr_11_mf_`i' if seed==0
	local `b'_mean=r(mean)
	disp ``b'_mean'
	local `b'_SD=r(sd)
	ge `i'_normalized=(ctr_11_mf_`i'-``b'_mean') / ``b'_SD'
	gen `i'_normalized_f=`i'_normalized if female == 1 
	replace `i'_normalized_f =. if female == 0
	gen `i'_normalized_m=`i'_normalized if female == 0
	replace `i'_normalized_m =. if female == 1
	label variable `i'_normalized "Normalized `i'"
	label variable `i'_normalized_f "Normalized `i' Female"
	label variable `i'_normalized_m "Normalized `i' Male"
}

ge dist_seed_f= dis_11_mf_seed if female==1
replace dist_seed_f=. if female==0

ge dist_seed_m= dis_11_mf_seed if female==0
replace dist_seed_m=. if female==1

foreach i in deg bet evc { 
			sum ctr_11_mf_`i', detail
			gen md_ctr_11_mf_`i'=r(p50) 
			gen p75_ctr_11_mf_`i'=r(p75) 
			
			gen dist_seed_`i'_high=dis_11_mf_seed if ctr_11_mf_`i' >= md_ctr_11_mf_`i' 
			replace dist_seed_`i'_high =. if ctr_11_mf_`i' < md_ctr_11_mf_`i'
			gen dist_seed_`i'_low=dis_11_mf_seed if ctr_11_mf_`i' < md_ctr_11_mf_`i'
			replace dist_seed_`i'_low =. if ctr_11_mf_`i' >= md_ctr_11_mf_`i'
			label variable dist_seed_`i'_high "Above median `i', dist to seed"
			label variable dist_seed_`i'_low "Below median `i', dist to seed"
			
			gen dist_seed_`i'_p75=dis_11_mf_seed if ctr_11_mf_`i' >= p75_ctr_11_mf_`i' 
			replace dist_seed_`i'_p75 =. if ctr_11_mf_`i' < p75_ctr_11_mf_`i'
			gen dist_seed_`i'_belowp75=dis_11_mf_seed if ctr_11_mf_`i' < p75_ctr_11_mf_`i'
			replace dist_seed_`i'_belowp75 =. if ctr_11_mf_`i' >= p75_ctr_11_mf_`i'
			label variable dist_seed_`i'_p75 "Above 75p `i', dist to seed"
			label variable dist_seed_`i'_belowp75 "Below 75p `i', dist to seed"			
		} 

label variable ctr_11_mf_deg_f "Degree Female"
label variable ctr_11_mf_deg_m "Degree Male"
label variable ctr_11_mf_bet_f "Betweeness Female"
label variable ctr_11_mf_bet_m "Betweeness Male"
label variable ctr_11_mf_evc_f "Eigenvector Female"
label variable ctr_11_mf_evc_m "Eigenvector Male"
label variable dist_seed_f "Women node dist to seed"
label variable dist_seed_m "Men node dist to seed"

#d ;
foreach var in ctr_11_mf_deg ctr_11_mf_bet ctr_11_mf_evc ctr_11_mf_deg_f ctr_11_mf_bet_f ctr_11_mf_evc_f ctr_11_mf_deg_m ctr_11_mf_bet_m ctr_11_mf_evc_m dist_seed_m dist_seed_f { ;
		forvalues n=0/2 { ;
			sum `var'  if treat==`n' ;
			matrix m`var'`n'=r(mean) ;
			matrix sd`var'`n'=r(sd) ;
		} ;
	local lbl`var': variable label `var' ;
	matrix `var'= m`var'2, m`var'1, m`var'0 \ sd`var'2, sd`var'1, sd`var'0 ;
	matrix rownames `var' = "`lbl`var''" "." ;
} ;
foreach var in deg_normalized deg_normalized_f deg_normalized_m bet_normalized bet_normalized_f bet_normalized_m evc_normalized evc_normalized_f evc_normalized_m { ;
		forvalues n=0/2 { ;
			sum `var'  if treat==`n' ;
			matrix m`var'`n'=r(mean) ;
			matrix sd`var'`n'=r(sd) ;
		} ;
	local lbl`var': variable label `var' ;
	matrix `var'= m`var'2, m`var'1, m`var'0 \ sd`var'2, sd`var'1, sd`var'0 ;
	matrix rownames `var' = "`lbl`var''" "." ;
} ;

foreach var in dist_seed_deg_high dist_seed_deg_low dist_seed_bet_high dist_seed_bet_low dist_seed_evc_high dist_seed_evc_low
dist_seed_deg_p75 dist_seed_deg_belowp75 dist_seed_bet_p75 dist_seed_bet_belowp75 dist_seed_evc_p75 dist_seed_evc_belowp75
 { ;
		forvalues n=0/2 { ;
			sum `var'  if treat==`n' ;
			matrix m`var'`n'=r(mean) ;
			matrix sd`var'`n'=r(sd) ;
		} ;
	local lbl`var': variable label `var' ;
	matrix `var'= m`var'2, m`var'1, m`var'0 \ sd`var'2, sd`var'1, sd`var'0 ;
	matrix rownames `var' = "`lbl`var''" "." ;
} ;

foreach var in dist_indirect dist_indirect_f dist_indirect_m notconnected {	;
		forvalues n=0/2 { ;
			sum `var'  if treat==`n' ;
			matrix m`var'`n'=r(mean) ;
			matrix N`var'`n'=r(N) ;
		} ;
	local lbl`var': variable label `var' ;
	matrix `var'= m`var'2, m`var'1, m`var'0 ;
	matrix N = Ndist_indirect2, Ndist_indirect1, Ndist_indirect0 ;
	matrix rownames `var' = "`lbl`var''" ;
	matrix rownames N = "Observations (Household-gender)" ;
} ;
	
matrix e_cont=ctr_11_mf_deg\ctr_11_mf_deg_f\ctr_11_mf_deg_m\deg_normalized\deg_normalized_f\deg_normalized_m\
			ctr_11_mf_bet\ctr_11_mf_bet_f\ctr_11_mf_bet_m\bet_normalized\bet_normalized_f\bet_normalized_m\
			ctr_11_mf_evc\ctr_11_mf_evc_f\ctr_11_mf_evc_m\evc_normalized\evc_normalized_f\evc_normalized_m\
			dist_seed_m\dist_seed_f\
			dist_seed_deg_high\dist_seed_deg_low\dist_seed_bet_high\dist_seed_bet_low\dist_seed_evc_high\dist_seed_evc_low\
			dist_seed_deg_p75\dist_seed_deg_belowp75\dist_seed_bet_p75\dist_seed_bet_belowp75\dist_seed_evc_p75\dist_seed_evc_belowp75\
			dist_indirect\dist_indirect_f\dist_indirect_m\notconnected\N ;

#d cr
frmttable using "$output\Table4", replace sdec(2, 2, 2) statmat(e_cont) title("Table 1. Panel B.") ///
	coljust(l;c) ctitles("" , Between, Degree, Random)


*************************** Table 5 *******************************
***************** Do the Treated Nodes Know More? *****************
*******************************************************************

lab var seed "Treated node"
areg know_simple seed  if any_treatment==0, absorb(vill_id) 
	sum  know_simple if seed==0 & any_treatment==0
	local mean=r(mean)
	local sd=r(sd)
eststo seed1, addscalars(Mean `mean' SD `sd')

noisily esttab seed1 using "$output\Table5.csv", scalars( Mean SD ) cells(b(star fmt(%9.3f))	///
	se(fmt(%9.3f))) starlevel(* .1 ** .05 *** .01) stardetach keep(seed) order(seed) label replace

*************************** Table 6 *******************************
******************** Diffusion of Calendars ***********************
*******************************************************************

lab var dist_seed2 "Direct Link"
lab var dist_indirect "Indirect Link"
lab var notconnected "Not Connected"

#d ;
reg receive_calendar dist_indirect notconnected female  dist_cf_indirect_bet dist_cf_indirect_deg ctr_11_mf_links_1away 
		ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away ctr_11_mf_links_6away 
		ctr_11_mf_links7ormore i.year if seed==0 & seed_in_HH==0 & cfact_11_deg==0 & cfact_08_bet==0, cluster(vill_id)	;
	test dist_indirect==notconnected ;
	local p_notconn=r(p) ;
	sum  receive_calendar if dist_seed2==1  & seed_in_HH==0 & cfact_11_deg==0 & cfact_08_bet==0 ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo calendar_1, addscalars(mean `mean' sd `sd' p_notconn `p_notconn') ;

reg receive_calendar dist_indirect notconnected dist_cf_indirect_bet dist_cf_indirect_deg ctr_11_mf_links_1away 
		ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away ctr_11_mf_links_6away 
		ctr_11_mf_links7ormore i.year if seed==0 & seed_in_HH==0 & female==0 & cfact_11_deg==0 & cfact_08_bet==0, 
		cluster(vill_id)	;
	test dist_indirect==notconnected ;
	local p_notconn=r(p) ;
	sum  receive_calendar if dist_seed2==1  & seed_in_HH==0 & female==0 & cfact_11_deg==0 & cfact_08_bet==0 ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo calendar_2, addscalars(mean `mean' sd `sd' p_notconn `p_notconn') ;

reg receive_calendar dist_indirect notconnected dist_cf_indirect_bet dist_cf_indirect_deg ctr_11_mf_links_1away 
		ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away ctr_11_mf_links_6away 
		ctr_11_mf_links7ormore i.year if seed==0 & seed_in_HH==0 & female==1 & cfact_11_deg==0 & cfact_08_bet==0, 
		cluster(vill_id) ;
	test dist_indirect==notconnected ;
	local p_notconn=r(p) ;
	sum  receive_calendar if dist_seed2==1  & seed_in_HH==0 & female==1 & cfact_11_deg==0 & cfact_08_bet==0 ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo calendar_3, addscalars(mean `mean' sd `sd' p_notconn `p_notconn') ;

noisily esttab calendar_1 calendar_2 calendar_3 using "$output\Table6.csv", 
	scalars(mean sd p_notconn) sfmt(%9.3f) cells(b(star fmt(%9.3f)) se(fmt(%9.3f))) 
	starlevel(* .1 ** .05 *** .01) stardetach keep(dist_indirect notconnected female) 
	order(dist_indirect notconnected female) style(tab) varwidth(8) modelwidth(8) 
	plain label margin replace ;


*** suest comparing men vs women coefficients ***;


reg receive_calendar dist_indirect notconnected dist_cf_indirect_bet dist_cf_indirect_deg ctr_11_mf_links_1away 
		ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away ctr_11_mf_links_6away 
		ctr_11_mf_links7ormore i.year if seed==0 & seed_in_HH==0 & female==0 & cfact_11_deg==0 & cfact_08_bet==0;
eststo calendar_male ;

reg receive_calendar dist_indirect notconnected dist_cf_indirect_bet dist_cf_indirect_deg ctr_11_mf_links_1away 
		ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away ctr_11_mf_links_6away 
		ctr_11_mf_links7ormore i.year if seed==0 & seed_in_HH==0 & female==1 & cfact_11_deg==0 & cfact_08_bet==0; 
eststo calendar_female; 	

suest calendar_male calendar_female, cluster(vill_id);

log using "$output\log_gendertests.log", append;
disp "Regressions of receive_calendar";
test [calendar_male_mean]dist_indirect==[calendar_female_mean]dist_indirect;
local gender_indirect=r(p);
test [calendar_male_mean]notconnected==[calendar_female_mean]notconnected;
local gender_noconn=r(p);
log close;

#d cr

*************************** Table 7 *******************************
******************* Knowledge of Composting ***********************
*******************************************************************

#d ;
reg know_simple dist_seed2 dist_indirect notconnected female cfact_11_deg cfact_08_bet dist_cf_direct_bet 
		dist_cf_indirect_bet dist_cf_direct_deg dist_cf_indirect_deg  ctr_11_mf_links_1away ctr_11_mf_links_2away 
		ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away ctr_11_mf_links_6away ctr_11_mf_links7ormore 
		i.year, cluster(vill_id) ;
	test dist_seed2==dist_indirect ;
	local p_indirect=r(p) ;
	test dist_indirect==notconnected ;
	local p_notconn=r(p) ;
	sum  know_simple if dist_seed1==1 ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo know_1, addscalars(mean `mean' sd `sd' p_indirect `p_indirect' p_notconn `p_notconn') ;

reg know_simple dist_seed2 dist_indirect notconnected cfact_11_deg cfact_08_bet dist_cf_direct_bet dist_cf_indirect_bet 
		dist_cf_direct_deg dist_cf_indirect_deg  ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away 
		ctr_11_mf_links_4away ctr_11_mf_links_5away ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if female==0, 
		cluster(vill_id) ;
test dist_seed2==dist_indirect ;
	local p_indirect=r(p) ;
	test dist_indirect==notconnected ;
	local p_notconn=r(p) ;
	sum  know_simple if dist_seed1==1 &  female==0 ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo know_2, addscalars(mean `mean' sd `sd' p_indirect `p_indirect' p_notconn `p_notconn') ;

reg know_simple dist_seed2 dist_indirect notconnected cfact_11_deg cfact_08_bet dist_cf_direct_bet dist_cf_indirect_bet 
		dist_cf_direct_deg dist_cf_indirect_deg  ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away 
		ctr_11_mf_links_4away ctr_11_mf_links_5away ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if female==1, 
		cluster(vill_id) ;
	test dist_seed2==dist_indirect ;
	local p_indirect=r(p) ;
	test dist_indirect==notconnected ;
	local p_notconn=r(p) ;
	sum  know_simple if dist_seed1==1 &  female==1 ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo know_3, addscalars(mean `mean' sd `sd' p_indirect `p_indirect' p_notconn `p_notconn') ;

*********** Sample of nodes that did not receive a calendar ***************;
	
ge nonseed_calendarreceipt=1 if receive_calendar==1 & seed==0;
replace nonseed_calendarreceipt=0 if seed==1 | receive_calendar==0;
	
	reg know_simple dist_seed2 dist_indirect notconnected female 
		cfact_11_deg cfact_08_bet dist_cf_direct_bet dist_cf_indirect_bet dist_cf_direct_deg dist_cf_indirect_deg  
		ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away 
		ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if nonseed_calendarreceipt==0, cluster(vill_id);	
	test dist_seed2==dist_indirect ;
	local p_indirect=r(p) ;
	test dist_indirect==notconnected ;
	local p_notconn=r(p) ;
	sum  know_simple if dist_seed1==1  ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo know_4, addscalars(mean `mean' sd `sd' p_indirect `p_indirect' p_notconn `p_notconn') ;

	
	reg know_simple dist_seed2 dist_indirect notconnected  
		cfact_11_deg cfact_08_bet dist_cf_direct_bet dist_cf_indirect_bet dist_cf_direct_deg dist_cf_indirect_deg  
		ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away 
		ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if nonseed_calendarreceipt==0 & female==0, cluster(vill_id);	
	test dist_seed2==dist_indirect ;
	local p_indirect=r(p) ;
	test dist_indirect==notconnected ;
	local p_notconn=r(p) ;
	sum  know_simple if dist_seed1==1 &  female==0 ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo know_5, addscalars(mean `mean' sd `sd' p_indirect `p_indirect' p_notconn `p_notconn') ;

	
	reg know_simple dist_seed2 dist_indirect notconnected
		cfact_11_deg cfact_08_bet dist_cf_direct_bet dist_cf_indirect_bet dist_cf_direct_deg dist_cf_indirect_deg  
		ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away 
		ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if nonseed_calendarreceipt==0 & female==1, cluster(vill_id);	
	test dist_seed2==dist_indirect ;
	local p_indirect=r(p) ;
	test dist_indirect==notconnected ;
	local p_notconn=r(p) ;
	sum  know_simple if dist_seed1==1 &  female==1 ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo know_6, addscalars(mean `mean' sd `sd' p_indirect `p_indirect' p_notconn `p_notconn') ;

foreach i in degree between {;
	foreach j in dist_seed2 dist_indirect notconnected {;
		ge `j'_`i'=`j'*`i'_treatment if `j'~=. & `i'_treatment~=.;
	};
};

reg know_simple dist_seed2 dist_indirect notconnected  dist_seed2_between dist_indirect_between notconnected_between dist_seed2_degree dist_indirect_degree notconnected_degree
		degree_treatment between_treatment cfact_11_deg cfact_08_bet dist_cf_direct_bet dist_cf_indirect_bet dist_cf_direct_deg dist_cf_indirect_deg  
		ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away 
		ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if female==0, cluster(vill_id);	
	test dist_seed2==dist_indirect ;
	local p_indirect=r(p) ;
	test dist_indirect==notconnected ;
	local p_notconn=r(p) ;
	sum  know_simple if dist_seed1==1 &  female==0 ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo know_7, addscalars(mean `mean' sd `sd' p_indirect `p_indirect' p_notconn `p_notconn') ;

	
	reg know_simple dist_seed2 dist_indirect notconnected  dist_seed2_between dist_indirect_between notconnected_between dist_seed2_degree dist_indirect_degree notconnected_degree
		degree_treatment between_treatment cfact_11_deg cfact_08_bet dist_cf_direct_bet dist_cf_indirect_bet dist_cf_direct_deg dist_cf_indirect_deg  
		ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away 
		ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if female==1, cluster(vill_id);	
	test dist_seed2==dist_indirect ;
	local p_indirect=r(p) ;
	test dist_indirect==notconnected ;
	local p_notconn=r(p) ;
	sum  know_simple if dist_seed1==1 &  female==1 ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo know_8, addscalars(mean `mean' sd `sd' p_indirect `p_indirect' p_notconn `p_notconn') ;



noisily esttab know_1 know_2 know_3 know_4 know_5 know_6 know_7 know_8 using "$output\Table7.csv", scalars(mean sd p_indirect p_notconn) 
	cells(b(star fmt(%9.3f)) se(fmt(%9.3f))) sfmt(%9.3f) starlevel(* .1 ** .05 *** .01) stardetach 
	keep(dist_seed2* dist_indirect* notconnected* female ) order(dist_seed2 dist_indirect notconnected female dist_seed2_between dist_indirect_between notconnected_between dist_seed2_degree dist_indirect_degree notconnected_degree) 
	style(tab) varwidth(8) modelwidth(8) plain label margin replace ;
	
	*** suest comparing men vs women coefficients for primary specification***;

reg know_simple dist_seed2 dist_indirect notconnected  
		cfact_11_deg cfact_08_bet dist_cf_direct_bet dist_cf_indirect_bet dist_cf_direct_deg dist_cf_indirect_deg  
		ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away 
		ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if female==0;
eststo know_male;

reg know_simple dist_seed2 dist_indirect notconnected
		cfact_11_deg cfact_08_bet dist_cf_direct_bet dist_cf_indirect_bet dist_cf_direct_deg dist_cf_indirect_deg  
		ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away 
		ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if female==1;
eststo know_female ;

suest know_male know_female, cluster(vill_id);

log using "$output\log_gendertests.log", append;
disp "Regressions of know_simple";
test [know_male_mean]dist_seed2==[know_female_mean]dist_seed2;
local gender_seed2=r(p);
test [know_male_mean]dist_indirect==[know_female_mean]dist_indirect;
local gender_indirect=r(p);
test [know_male_mean]notconnected==[know_female_mean]notconnected;
local gender_noconn=r(p);
log close;

#d cr

*************************** Table 8 *******************************
********** Village-level Treatments: Knowledge and Gender *********
*******************************************************************

foreach i in degree between any {

	ge `i'_treat_female=`i'_treatment*female
	
	}
	
lab var degree_treatment "1 If Treated Using Degree Targeting"
lab var between_treatment "1 If Treated Using Betweeness Targeting"
lab var degree_treat_female "Degree Treatment * Female"
lab var between_treat_female "Betweeness Treatment * Female"

	** Village level treatment variation **

foreach i in degree between {
	foreach j in ctr_11_mf_deg ctr_11_mf_bet ctr_11_mf_clo ctr_11_mf_evc {
	ge `j'_`i't=`i'_treatment*`j'
	}
	foreach j in ctr_11_mf_deg_rank ctr_11_mf_bet_rank ctr_11_mf_clo_rank ctr_11_mf_evc_rank {
	ge `j'rank_`i't=`i'_treatment*`j'
	}
	foreach j in deg bet clo evc {
	ge `j'_`i't=`j'_normalized*`i'_treatment
	}
}


xi: reg know_simple degree_treatment between_treatment i.numfemaleseeds_rand*female villagesize_recip i.year  if seed==0 & cfact_08_bet==0 & cfact_11_deg==0, cluster(vill_id)	
sum know_simple if degree_treatment==0 & between_treatment==0 & seed==0
	local mean=r(mean)
	local sd=r(sd)
eststo villagetreat_w1, addscalars(mean `mean' sd `sd')
	
xi: reg know_simple degree_treatment between_treatment degree_treat_female between_treat_female i.numfemaleseeds_rand*female villagesize_recip i.year if seed==0 & cfact_08_bet==0 & cfact_11_deg==0, cluster(vill_id)	
	test degree_treat_female==between_treat_female
	local p_hetero=r(p)
eststo villagetreat_w2, addscalars (p_hetero `p_hetero')


** Now looking just at villages which were (randomly) allocated 2 female seeds and 2 male seeds **


xi: reg know_simple degree_treatment between_treatment female villagesize_recip i.year  if seed==0 & numfemaleseeds_rand==2, cluster(vill_id)	
sum know_simple if degree_treatment==0 & between_treatment==0 & seed==0
	local mean=r(mean)
	local sd=r(sd)
eststo villagetreat_w3, addscalars(mean `mean' sd `sd')
	
xi: reg know_simple degree_treatment between_treatment degree_treat_female between_treat_female female villagesize_recip i.year if seed==0 & numfemaleseeds_rand==2 & cfact_08_bet==0 & cfact_11_deg==0, cluster(vill_id)	
	test degree_treat_female==between_treat_female
	local p_hetero=r(p)
eststo villagetreat_w4, addscalars (p_hetero `p_hetero')


** Robustness: now including just numfemaleseeds_rand*female


ge nfemaleseeds_female=numfemaleseeds_rand*female


xi: reg know_simple degree_treatment between_treatment nfemaleseeds_female numfemaleseeds_rand female villagesize_recip i.year  if seed==0 & cfact_08_bet==0 & cfact_11_deg==0, cluster(vill_id)	
sum know_simple if degree_treatment==0 & between_treatment==0 & seed==0
	local mean=r(mean)
	local sd=r(sd)
eststo villagetreat_w5, addscalars(mean `mean' sd `sd')
	
xi: reg know_simple degree_treatment between_treatment degree_treat_female between_treat_female nfemaleseeds_female numfemaleseeds_rand female villagesize_recip i.year if seed==0 & cfact_08_bet==0 & cfact_11_deg==0, cluster(vill_id)	
	test degree_treat_female==between_treat_female
	local p_hetero=r(p)
eststo villagetreat_w6, addscalars (p_hetero `p_hetero')


** Robustness: controlling for having 2 or more femael seeds in a village


ge lesshalf=numfemaleseeds_rand<2
ge halformore=numfemaleseeds_rand>=2


foreach i in lesshalf halformore {
	ge `i'_female=`i'*female
}

xi: reg know_simple degree_treatment between_treatment degree_treat_female between_treat_female female lesshalf lesshalf_female  villagesize_recip i.year if seed==0 & cfact_08_bet==0 & cfact_11_deg==0, cluster(vill_id)
	test degree_treat_female==between_treat_female
	local p_hetero=r(p)
eststo villagetreat_w7, addscalars (p_hetero `p_hetero')

#delimit;
noisily esttab villagetreat_w1 villagetreat_w2 villagetreat_w3 villagetreat_w4 villagetreat_w5 villagetreat_w6  villagetreat_w7 using "$output\Table8.csv", scalars(mean sd p_hetero) cells(b(star fmt(%9.3f)) se(fmt(%9.3f))) sfmt(%9.3f) 
starlevel(* .1 ** .05 *** .01) stardetach keep(degree_treatment between_treatment female degree_treat_female between_treat_female lesshalf lesshalf_female villagesize_recip) 
order(degree_treatment between_treatment female degree_treat_female between_treat_female lesshalf lesshalf_female villagesize_recip) style(tab) varwidth(8) modelwidth(8) 
plain label margin replace;

#delimit cr

*************************** Table 9 *******************************
**************** Knowledge and Social Distance ********************
*******************************************************************

#d ;
foreach j in deg bet evc { ;
	xi: reg know_simple degree_treatment between_treatment `j'_normalized `j'_degreet `j'_betweent i.numfemaleseeds_rand*female 
			villagesize_recip   i.year if seed==0 & cfact_08_bet==0 & cfact_11_deg==0, cluster(vill_id) ;
	sum know_simple if degree_treatment==0 & between_treatment==0 & seed==0  ;
		local mean=r(mean) ;
		local sd=r(sd) ;
		
		test `j'_degreet ==`j'_betweent ;
		local p_hetero=r(p) ;
	
	eststo villagetreat_`j'1, addscalars(mean `mean' sd `sd' p_hetero `p_hetero') ;

	xi: reg know_simple degree_treatment between_treatment `j'_normalized `j'_degreet `j'_betweent i.numfemaleseeds_rand 
			villagesize_recip  i.year if seed==0 & female==0 & cfact_08_bet==0 & cfact_11_deg==0, cluster(vill_id) ;
	sum know_simple if degree_treatment==0 & between_treatment==0 & seed==0 & female==0 ;
		local mean=r(mean) ;
		local sd=r(sd) ;
		
		test `j'_degreet ==`j'_betweent ;
		local p_hetero=r(p) ;
		
	eststo villagetreat_`j'2, addscalars(mean `mean' sd `sd' p_hetero `p_hetero') ;

	xi: reg know_simple degree_treatment between_treatment `j'_normalized `j'_degreet `j'_betweent i.numfemaleseeds_rand*female 
			villagesize_recip  i.year if seed==0 & female==1 & cfact_08_bet==0 & cfact_11_deg==0, cluster(vill_id) ;
	sum know_simple if degree_treatment==0 & between_treatment==0 & seed==0 & female==1 ;
		local mean=r(mean) ;
		local sd=r(sd) ;
		
		test `j'_degreet ==`j'_betweent ;
		local p_hetero=r(p) ;	
		
	eststo villagetreat_`j'3, addscalars(mean `mean' sd `sd' p_hetero `p_hetero') ;
} ;
noisily esttab villagetreat_deg1 villagetreat_bet1 villagetreat_evc1 villagetreat_deg2 villagetreat_bet2 villagetreat_evc2 
	villagetreat_deg3 villagetreat_bet3 villagetreat_evc3 using "$output\Table9.csv", scalars(mean sd p_hetero) sfmt(%9.3f)
	cells(b(star fmt(%9.3f)) se(fmt(%9.3f))) starlevel(* .1 ** .05 *** .01) stardetach keep(degree_treatment between_treatment 
	deg_normalized deg_degreet deg_betweent bet_normalized bet_degreet bet_betweent evc_normalized evc_degreet evc_betweent) 
	order(degree_treatment between_treatment deg_normalized deg_degreet deg_betweent bet_normalized bet_degreet bet_betweent 
	evc_normalized evc_degreet evc_betweent) style(tab) varwidth(8) modelwidth(8) plain label margin replace ;
#d cr


**** Table 9 using 75 percentile instead of linear *****

foreach i in deg bet evc { 
			sum ctr_11_mf_`i', detail
			gen p25_ctr_11_mf_`i'=r(p25)
			*gen p75_ctr_11_mf_`i'=r(p75)
			gen p50_ctr_11_mf_`i'=r(p50)			
			gen dist_seed_band_`i'=dis_11_mf_seed if ctr_11_mf_`i' < p75_ctr_11_mf_`i'
			replace dist_seed_band_`i'=. if ctr_11_mf_`i' >= p75_ctr_11_mf_`i'
			label variable dist_seed_band_`i' "Within band `i', dist to seed"
		} 

	foreach j in 25 50 75 {
		ge evc_above`j'p=1 if ctr_11_mf_evc >= p`j'_ctr_11_mf_evc
		replace evc_above`j'p=0 if ctr_11_mf_evc < p`j'_ctr_11_mf_evc
		replace evc_above`j'p=. if ctr_11_mf_evc==.
		
		ge deg_above`j'p=1 if ctr_11_mf_deg >= p`j'_ctr_11_mf_deg
		replace deg_above`j'p=0 if ctr_11_mf_deg < p`j'_ctr_11_mf_deg
		replace deg_above`j'p=. if ctr_11_mf_deg==.
		
		ge bet_above`j'p=1 if ctr_11_mf_bet >= p`j'_ctr_11_mf_bet
		replace bet_above`j'p=0 if ctr_11_mf_bet < p`j'_ctr_11_mf_bet
		replace bet_above`j'p=. if ctr_11_mf_bet==.
	
		foreach i in between degree {

	ge evc_above`j'p_`i't=evc_above`j'p*`i'_treatment
	ge deg_above`j'p_`i't=deg_above`j'p*`i'_treatment	
	ge bet_above`j'p_`i't=bet_above`j'p*`i'_treatment		
	}
	
}

#delimit;

estimates clear;


foreach i in deg bet evc { ;

xi: reg know_simple degree_treatment between_treatment `i'_above75p `i'_above75p_degreet `i'_above75p_betweent 
i.numfemaleseeds_rand*female villagesize_recip  i.year if seed==0  & cfact_08_bet==0 & cfact_11_deg==0, cluster(vill_id);
	sum know_simple if degree_treatment==0 & between_treatment==0 & seed==0;
		local mean=r(mean) ;
		local sd=r(sd) ;
		test `i'_above75p_degreet ==`i'_above75p_betweent ;
		local p_hetero=r(p) ;
	eststo villagetreat_`i'1, addscalars(mean `mean' sd `sd' p_hetero `p_hetero') ;
	
	
xi: reg know_simple degree_treatment between_treatment `i'_above75p `i'_above75p_degreet `i'_above75p_betweent 
i.numfemaleseeds_rand*female villagesize_recip  i.year if seed==0 & female==0 & cfact_08_bet==0 & cfact_11_deg==0, cluster(vill_id);
	sum know_simple if degree_treatment==0 & between_treatment==0 & seed==0 & female==0 ;
		local mean=r(mean) ;
		local sd=r(sd) ;
		test `i'_above75p_degreet ==`i'_above75p_betweent ;
		local p_hetero=r(p) ;		
	eststo villagetreat_`i'2, addscalars(mean `mean' sd `sd' p_hetero `p_hetero') ;
	
	xi: reg know_simple degree_treatment between_treatment `i'_above75p `i'_above75p_degreet `i'_above75p_betweent 
i.numfemaleseeds_rand*female villagesize_recip  i.year if seed==0 & female==1 & cfact_08_bet==0 & cfact_11_deg==0, cluster(vill_id);
	sum know_simple if degree_treatment==0 & between_treatment==0 & seed==0 & female==1 ;
		local mean=r(mean) ;
		local sd=r(sd) ;
		test `i'_above75p_degreet ==`i'_above75p_betweent ;
		local p_hetero=r(p) ;		
	eststo villagetreat_`i'3, addscalars(mean `mean' sd `sd' p_hetero `p_hetero') ;
	
	
};


noisily esttab villagetreat_deg1 villagetreat_bet1 villagetreat_evc1 villagetreat_deg2 villagetreat_bet2 villagetreat_evc2 
	villagetreat_deg3 villagetreat_bet3 villagetreat_evc3 using "$output\Table9_p75.csv", scalars(mean sd p_hetero) sfmt(%9.3f)
	cells(b(star fmt(%9.3f)) se(fmt(%9.3f))) starlevel(* .1 ** .05 *** .01) stardetach keep(degree_treatment between_treatment 
	deg_above75p deg_above75p_degreet deg_above75p_betweent bet_above75p bet_above75p_degreet bet_above75p_betweent evc_above75p evc_above75p_degreet evc_above75p_betweent) 
	order(degree_treatment between_treatment 
	deg_above75p deg_above75p_degreet deg_above75p_betweent bet_above75p bet_above75p_degreet bet_above75p_betweent evc_above75p evc_above75p_degreet evc_above75p_betweent) style(tab) varwidth(8) modelwidth(8) plain label margin replace ;



*********************** Appendix Table 1 **************************
************ Diffusion of Calendars by Social Distance ************
*******************************************************************

lab var dist_seed2 "Distance 1 (direct links)"
lab var dist_seed3 "Distance 2 (indirect links)"
lab var dist_seed4 "Distance 3"
lab var dist_seed5 "Distance 4"
lab var dist_seed6 "Distance 5"	
lab var dist_seed7 "Distance 6"	
#d ;
reg receive_calendar dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected female 
	dist_cf_indirect_bet dist_cf_indirect_deg ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away 
	ctr_11_mf_links_4away ctr_11_mf_links_5away 
	ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year  if  seed==0 & seed_in_HH==0 & cfact_11_deg==0 & cfact_08_bet==0, 
		cluster(vill_id);
	sum  receive_calendar if seed_in_HH==0 & dist_seed2==1;
	local mean=r(mean);
	local sd=r(sd);
eststo calendar_app_1a, addscalars(mean `mean' sd `sd') ;

reg receive_calendar dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected female i.year if seed==0 & 
		seed_in_HH==0, cluster(vill_id);
	sum  receive_calendar if seed_in_HH==0 & dist_seed2==1;
	local mean=r(mean);
	local sd=r(sd);
eststo calendar_app_1b, addscalars(mean `mean' sd `sd') ;

reg receive_calendar  dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected 
		dist_cf_indirect_bet dist_cf_indirect_deg ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away 
		ctr_11_mf_links_4away ctr_11_mf_links_5away ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if seed==0 & 
		female==0 & seed_in_HH==0 & cfact_11_deg==0 & cfact_08_bet==0, cluster(vill_id);
	sum  receive_calendar if seed_in_HH==0 & dist_seed2==1 & female==0;
	local mean=r(mean);
	local sd=r(sd);
eststo calendar_app_2a, addscalars(mean `mean' sd `sd') ;

reg receive_calendar dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected i.year if seed==0 & female==0 
		& seed_in_HH==0, cluster(vill_id);
	sum  receive_calendar if seed_in_HH==0 & dist_seed2==1 & female==0;
	local mean=r(mean);
	local sd=r(sd);
eststo calendar_app_2b, addscalars(mean `mean' sd `sd') ;

reg receive_calendar dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected 
		dist_cf_indirect_bet dist_cf_indirect_deg ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away 
		ctr_11_mf_links_4away ctr_11_mf_links_5away ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if seed==0 & 
		female==1 & seed_in_HH==0 & cfact_11_deg==0 & cfact_08_bet==0, cluster(vill_id) ;
	sum  receive_calendar if seed_in_HH==0 & dist_seed2==1 & female==1 ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo calendar_app_3a, addscalars(mean `mean' sd `sd') ;

reg receive_calendar dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected i.year if seed==0 & female==1 
		& seed_in_HH==0, cluster(vill_id) ;
	sum  receive_calendar if seed_in_HH==0 & dist_seed2==1 & female==1 ;
	local mean=r(mean) ;
	local sd=r(sd) ;
eststo calendar_app_3b, addscalars(mean `mean' sd `sd') ;

noisily esttab calendar_app_1* calendar_app_2* calendar_app_3* using "$output\TableA1.csv", scalars(mean sd) sfmt(%9.3f)
	cells(b(star fmt(%9.3f)) se(fmt(%9.3f))) starlevel(* .1 ** .05 *** .01) stardetach keep(dist_seed3 dist_seed4 dist_seed5 
	dist_seed6 dist_seed7 notconnected  female) order(dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected 
	female) style(tab) varwidth(8) modelwidth(8) plain label margin replace;
#d cr

*********************** Appendix Table 2 **************************
**************** Knowledge and Social Distance ********************
*******************************************************************

#d ;
reg know_simple dist_seed2 dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected female 
		cfact_11_deg cfact_08_bet dist_cf_direct_bet dist_cf_indirect_bet dist_cf_direct_deg dist_cf_indirect_deg
		ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away 
		ctr_11_mf_links_6away  ctr_11_mf_links7ormore i.year, cluster(vill_id);
	sum  know_simple if dist_seed1==1;
	local mean=r(mean);
	local sd=r(sd);
eststo know_app_1a, addscalars(mean `mean' sd `sd');

reg know_simple dist_seed2 dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected female i.year, cluster(vill_id);
	sum know_simple if dist_seed1==1;
	local mean=r(mean);
	local sd=r(sd);
eststo know_app_1b, addscalars(mean `mean' sd `sd');

reg know_simple dist_seed2 dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected 
		cfact_11_deg cfact_08_bet dist_cf_direct_bet dist_cf_indirect_bet dist_cf_direct_deg dist_cf_indirect_deg
		ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away 
		ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if female==0, cluster(vill_id);
	sum  know_simple if dist_seed1==1 & female==0;
	local mean=r(mean);
	local sd=r(sd);
eststo know_app_2a, addscalars(mean `mean' sd `sd');

reg know_simple dist_seed2 dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected i.year if female==0, 
		cluster(vill_id);
	sum know_simple if dist_seed1==1 & female==0;
	local mean=r(mean);
	local sd=r(sd);
eststo know_app_2b, addscalars(mean `mean' sd `sd');

reg know_simple dist_seed2 dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected 
		cfact_11_deg cfact_08_bet dist_cf_direct_bet dist_cf_indirect_bet dist_cf_direct_deg dist_cf_indirect_deg
		ctr_11_mf_links_1away ctr_11_mf_links_2away ctr_11_mf_links_3away ctr_11_mf_links_4away ctr_11_mf_links_5away 
		ctr_11_mf_links_6away ctr_11_mf_links7ormore i.year if female==1;
	sum know_simple if dist_seed1==1 & female==1;
	local mean=r(mean);
	local sd=r(sd);
eststo know_app_3a, addscalars(mean `mean' sd `sd');

reg know_simple dist_seed2 dist_seed3 dist_seed4 dist_seed5 dist_seed6 dist_seed7 notconnected i.year if female==1;
	sum  know_simple if dist_seed1==1 & female==1;
	local mean=r(mean);
	local sd=r(sd);
eststo know_app_3b, addscalars(mean `mean' sd `sd');

noisily esttab know_app_1* know_app_2* know_app_3* using "$output\TableA2.csv", scalars(mean sd) sfmt(%9.3f) 
	cells(b(star fmt(%9.3f)) se(fmt(%9.3f))) starlevel(* .1 ** .05 *** .01) stardetach keep(dist_seed2 dist_seed3 dist_seed4 
	dist_seed5 dist_seed6 dist_seed7 notconnected female) order(dist_seed2 dist_seed3 dist_seed4 dist_seed5 dist_seed6 
	dist_seed7 notconnected female) style(tab) varwidth(8) modelwidth(8) plain label margin replace;
#d cr

